<template>
	<header class="header">
		<h1>小黑记事本</h1>
		<input placeholder="请输入任务" class="new-todo" :value="value" @input="$emit('input',$event.target.value)" />
		<!-- <input placeholder="请输入任务" class="new-todo" v-model="task" @keyup.enter="onsubmit" /> -->
		<button class="add">添加任务</button>
	</header>
</template>
<script>
import EventBus from '@/utils/EventBus.js'
export default {
	data() {
		return {
			task: ''
		}
	},
	props: {
		value:String
	},
	methods: {
		onsubmit() {
			// this.$emit('add', this.task)
			EventBus.$emit('add', this.task)
			this.task = ''
		}
	}
}
</script>
